package com.CST.controller.cb;

import com.CST.common.api.Response;
import com.CST.common.api.ResultObject;
import com.CST.entity.cb.BdItemcompare;
import com.CST.service.cb.BdItemcompareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author nmx
 * @since 2024-04-23
 */
@Api(tags = {"bdItemcompare"})
@RestController
@RequestMapping("/bdItemcompare")
public class BdItemcompareController {
    @Autowired
    private BdItemcompareService bdItemcompareService;

    @PostMapping("/modifyEnumDetail")
    @ApiOperation("修改字典数据 必传参数:edId:选择修改记录edId")
    public ResultObject modifyEnumDetail(@RequestBody BdItemcompare entity) {
        if (entity.getEdEdId().equals(0) || entity.getEdName().isEmpty() || entity.getEdParentCode().isEmpty()) {
            return ResultObject.errorReturn("枚举edParentCode值/院区edEdId/名称edName不能为空");
        }
        boolean flag = bdItemcompareService.saveOrUpdate(entity);
        return ResultObject.successReturn(flag);
    }


    @GetMapping("/delete")
    @ApiOperation("删除字典数据 必传参数:edId:选择删除记录edId")
    public ResultObject delete(@RequestParam("edId") Integer edId) {
        boolean flag = bdItemcompareService.removeById(edId);
        return ResultObject.successReturn(flag);
    }
}
